﻿using ConfExpert.Datasets;
using ConfExpert.Forms.Base;
using ConfExpert.Utility;
using DevTeam;
using System;
using System.Data;
using System.Windows.Forms;

namespace ConfExpert.Forms.Siparisler
{
    public partial class SiparisDosyaBilgileri : XForm
    {
        DataTable dt;
        string idx;
        string tip = "F";
        public SiparisDosyaBilgileri()
        {
            InitializeComponent();
        }
        public SiparisDosyaBilgileri(string _idx, DataTable _dt)
            : this()
        {
            dt = _dt;
            idx = _idx;
        }

        private void SiparisDosyaBilgileri_Load(object sender, EventArgs e)
        {
            lblAdet.Text = dt.Compute("sum(Total)", "").ToString();
            //txtModel.Text = dt.Rows[0]["StyleId"].ToString();
            MyData.StyleRow r = AppSession.Lookups.Style.FindByStyleId(dt.Rows[0]["StyleId"].ToInt(-1));
            txtModel.Text = r["Style"].ToString();
            gleAtolye.Properties.Assign(RI(Rp.V_CariA));

            cbTip.SelectedIndexChanged += new EventHandler(cbTip_SelectedIndexChanged);
            btnOk.Click+=new EventHandler(btnOk_Click);
            btnCancel.Click+=new EventHandler(btnCancel_Click);
        }

        void cbTip_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (cbTip.SelectedIndex)
            {
                case 0:
                    tip = "F";
                    break;
                case 1:
                    tip = "K";
                    break;
                case 2:
                    tip = "N";
                    break;
            } 
        }

        void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        void btnOk_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            Session.DataManager.ExecuteDataSet("UpdOrdersKesimNo", idx, txtModel.Text, txtNot.Text, WhoAmI, tip,gleAtolye.EditValue);
        }
    }
}